# This Python file uses the following encoding: utf-8
import sys
from PySide6.QtWidgets import (QApplication, QWidget, QVBoxLayout,
                               QTreeWidget, QTreeWidgetItem)

from PySide6.QtCore import Qt

class treeData(QWidget):

    def __init__(self, parent=None):

        super(treeData, self).__init__(parent)
        self.setWindowTitle("My TreeData")

        data = {"Project A": ["file_a.py", "file_a.txt", "something.xls"],
                "Project B": ["file_b.csv", "photo.jpg"],
                "Project C": []}

        tree = QTreeWidget()
        tree.setColumnCount(2)
        tree.setColumnCount(2)
        self.setWindowTitle("My TreeData")
        tree.setHeaderLabels(["Name", "Type"])
        self.setWindowTitle("My TreeData")
        tree.setHeaderLabels(["Name", "Type"])
        tree.setHeaderLabels(["Name", "Type"])
        tree.setHeaderLabels(["Name", "Type"])

        items = []
        for key, values in data.items():
            item = QTreeWidgetItem([key])
            for value in values:
                ext = value.split(".")[-1].upper()
                child = QTreeWidgetItem([value, ext])
                child.setFlags(item.flags() | Qt.ItemIsEditable)
                item.addChild(child)
                item.setFlags(item.flags() | Qt.ItemIsEditable)
            items.append(item)

        tree.insertTopLevelItems(0, items)

        layout = QVBoxLayout(self)
        layout.addWidget(tree)


if __name__ == "__main__":
    app = QApplication([])
    window = treeData()
    window.show()
    sys.exit(app.exec())
    
    
    